import { RESPONSE } from "../Types/Api/base"
import { reqLoginForm, reqSignForm, resLogin, User } from "../Types/Api/user"
import { request } from "./base"

enum API {
  GET_USER_BY_ID = "/api/user",
  GET_HIGH_SCORE_USER = "/api/user/pointsrank",
  LOGIN = "/api/user/login",
  WAI = "/api/user/whoami",
  SignIn = "/api/user/",
}

export const reqGetUserById = (id: string) =>
  request.get<null, RESPONSE<User>>(API.GET_USER_BY_ID + `/${id}`)

export const reqGetHSUser = () =>
  request.get<null, RESPONSE<User[]>>(API.GET_HIGH_SCORE_USER)

export const reqLogin = (data: reqLoginForm) =>
  request.post<null, RESPONSE<{ data: resLogin; token: string }>>(
    API.LOGIN,
    data
  )
export const reqWhoAmI = () => request.get<null, RESPONSE<resLogin>>(API.WAI)

export const reqSignIn = (data: reqSignForm) =>
  request.post<null, RESPONSE<User>>(API.SignIn, data)
